package com.foxzzz.base;

public class GenUtil {
    public static int[][] genIntTestCast(String test, int w, int h) {
        int[][] result = new int[w][h];
        String strs[] = test.replace("[", "").replace("]", "").replace("\"", "").split(",");
        for (int i = 0; i < strs.length; i++) {
            int y = i / h;
            int x = i % w;
            result[x][y] = Integer.parseInt(strs[i].trim().substring(0, 1));
        }
        return result;
    }

    public static char[][] genCharTestCast(String test, int w, int h) {
        char[][] result = new char[h][w];
        String strs[] = test.replace("[", "").replace("]", "").replace("\"", "").split(",");
        for (int i = 0; i < strs.length; i++) {
            int x = i % w;
            int y = (i - 1) / w;
            result[y][x] = strs[i].charAt(0);
            if (x == 0)
                System.out.println();
            System.out.print(result[y][x] + " ");

        }
        System.out.println();
        return result;
    }

}
